package com.tuomaxu.core;

import org.springframework.web.WebApplicationInitializer;

import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.HandlesTypes;
import java.lang.reflect.InvocationTargetException;
import java.util.Set;


@HandlesTypes(value={WebApplicationInitializer.class})
public class MySpringServletContainerInitializer implements ServletContainerInitializer {

    public MySpringServletContainerInitializer(){

    }
    @Override
    public void onStartup(Set<Class<?>> set, ServletContext servletContext) throws ServletException {
        System.out.println("MySpringServletContainerInitializer");
//        for (Class<?> aClass : set) {
//            if(!aClass.getName().equals("com.tuomaxu.core.MyWebApplicationInitializer")){
//                continue;
//            }
//            try {
//                WebApplicationInitializer initializer = (WebApplicationInitializer)aClass.getDeclaredConstructor().newInstance();
//                initializer.onStartup(servletContext);
//            } catch (InstantiationException e) {
//                e.printStackTrace();
//            } catch (IllegalAccessException e) {
//                e.printStackTrace();
//            } catch (InvocationTargetException e) {
//                e.printStackTrace();
//            } catch (NoSuchMethodException e) {
//                e.printStackTrace();
//            }
//
//        }
    }
}
